<template>
  <div class="content-div">
    <ul class="product-content"  @click="productevent">
      <li>
        <img v-if="c.picUrl !== undefined" :src="c.picUrl" />
      </li>
      <li>
        <flexbox orient="vertical">
          <flexbox-item><div class="flex-demo contentdec">{{c.title}}</div></flexbox-item>
          <p>{{c.createTime}}</p>
          <flexbox-item>
            <div class="flex-demo content-bottom">
              <flexbox>
                <flexbox-item><div class="flex-demo"><img src="../../static/img/yueduliang@2x.png"/>{{c.readCnt}}</div></flexbox-item>
                <flexbox-item><div class="flex-demo"><img src="../../static/img/zhuanfaliang@2x.png"/>{{c.shareCnt}}</div></flexbox-item>
                <flexbox-item><div class="flex-demo"><span @click.self.stop="sharedown(keyindex)">点击分享</span></div></flexbox-item>
              </flexbox>
            </div>
          </flexbox-item>
        </flexbox>
      </li>
      <div class="clear"></div>
    </ul>
  </div>
</template>
<script>
import { Flexbox, FlexboxItem } from 'vux'
import api from '../api'
import utils from '../utils'
export default {
  props: ['c', 'keyindex'],
  components: {
    Flexbox,
    FlexboxItem
  },
  methods: {
    productevent () {
      window.location.href = '/article/detail?article_id=' + this.c.id + '&partnerId=' + this.c.partnerId
    },
    sharedown (index) {
      this.$emit('sharefriend')
      this.WXshare()
    },
    WXshare () {
      var sharetitle = this.c.title
      var shareimg = this.c.picUrl
      var sharedesc = this.c.summary
      var shareUrl = this.$store.state.Url + '/article/detail_out'
      var shareParams
      if (this.c.partnerId) {
        shareParams = '?shareParam=share&userId=' + this.$store.state.userID + '&postId=' + this.c.id + '&partnerId=' + this.c.partnerId
      } else {
        shareParams = '?shareParam=share&userId=' + this.$store.state.userID + '&postId=' + this.c.id
      }
      this.$store.commit('changeIndexConf', {
        shareTitle: sharetitle,
        shareDesc: sharedesc,
        shareImg: shareimg,
        shareLink: shareUrl + shareParams
      })
      var contentshare = true
      utils.refreshShare( this.$wechat, this.$store, api, contentshare, this.c.id)
    }
  }
}
</script>
